package com.appoint.web.controller.buss;

import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.appoint.buss.domain.req.EpiparaChipSeqReqVO;
import com.appoint.buss.domain.vo.EpiparaChipSeqRespVO;
import com.appoint.common.annotation.Anonymous;
import com.squareup.okhttp.OkHttpClient;
import com.squareup.okhttp.Request;
import com.squareup.okhttp.Response;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.appoint.common.annotation.Log;
import com.appoint.common.core.controller.BaseController;
import com.appoint.common.core.domain.AjaxResult;
import com.appoint.common.enums.BusinessType;
import com.appoint.buss.domain.EpiparaChipSeq;
import com.appoint.buss.service.IEpiparaChipSeqService;
import com.appoint.common.utils.poi.ExcelUtil;
import com.appoint.common.core.page.TableDataInfo;
import org.springframework.web.multipart.MultipartFile;

/**
 * epipara_chip_seqController
 *
 * @author appoint
 * @date 2023-01-15
 */
@RestController
@RequestMapping("/buss/chipSeq")
public class EpiparaChipSeqController extends BaseController
{
    @Autowired
    private IEpiparaChipSeqService epiparaChipSeqService;

    /**
     * 查询epipara_chip_seq列表
     */
    @PreAuthorize("@ss.hasPermi('buss:chipSeq:list')")
    @GetMapping("/list")
    public TableDataInfo list(EpiparaChipSeq epiparaChipSeq)
    {
        startPage();
        List<EpiparaChipSeq> list = epiparaChipSeqService.selectEpiparaChipSeqList(epiparaChipSeq);
        return getDataTable(list);
    }

    /**
     * 导出epipara_chip_seq列表
     */
    @PreAuthorize("@ss.hasPermi('buss:chipSeq:export')")
    @Log(title = "epipara_chip_seq", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, EpiparaChipSeq epiparaChipSeq)
    {
        List<EpiparaChipSeq> list = epiparaChipSeqService.selectEpiparaChipSeqList(epiparaChipSeq);
        ExcelUtil<EpiparaChipSeq> util = new ExcelUtil<EpiparaChipSeq>(EpiparaChipSeq.class);
        util.exportExcel(response, list, "epipara_chip_seq数据");
    }

    /**
     * 获取epipara_chip_seq详细信息
     */
    @PreAuthorize("@ss.hasPermi('buss:chipSeq:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") String id)
    {
        return AjaxResult.success(epiparaChipSeqService.selectEpiparaChipSeqById(id));
    }

    /**
     * 新增epipara_chip_seq
     */
    @PreAuthorize("@ss.hasPermi('buss:chipSeq:add')")
    @Log(title = "epipara_chip_seq", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody EpiparaChipSeq epiparaChipSeq)
    {
        return toAjax(epiparaChipSeqService.insertEpiparaChipSeq(epiparaChipSeq));
    }

    /**
     * 修改epipara_chip_seq
     */
    @PreAuthorize("@ss.hasPermi('buss:chipSeq:edit')")
    @Log(title = "epipara_chip_seq", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody EpiparaChipSeq epiparaChipSeq)
    {
        return toAjax(epiparaChipSeqService.updateEpiparaChipSeq(epiparaChipSeq));
    }

    /**
     * 删除epipara_chip_seq
     */
    @PreAuthorize("@ss.hasPermi('buss:chipSeq:remove')")
    @Log(title = "epipara_chip_seq", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(epiparaChipSeqService.deleteEpiparaChipSeqByIds(ids));
    }

    @Log(title = "信息导入", businessType = BusinessType.IMPORT)
    @PreAuthorize("@ss.hasPermi('buss:chipSeq:import')")
    @PostMapping("/importData")
    public AjaxResult importData(MultipartFile file, boolean updateSupport) throws Exception
    {
        ExcelUtil<EpiparaChipSeq> util = new ExcelUtil<>(EpiparaChipSeq.class);
        List<EpiparaChipSeq> list = util.importExcel(file.getInputStream());
        String operName = getUsername();
        String message = epiparaChipSeqService.importUser(list, updateSupport, operName);
        return AjaxResult.success(message);
    }

    /**
     * 查询epipara_chip_seq列表
     */
    @Anonymous
    @GetMapping("/list2")
    public TableDataInfo list2(EpiparaChipSeqReqVO reqVO)
    {
        startPage();
        List<EpiparaChipSeqRespVO> list = epiparaChipSeqService.list2(reqVO);
        return getDataTable(list);
    }

    /**
     * 导出epipara_chip_seq列表
     */
    @Anonymous
    @PostMapping("/list2Export")
    public void list2Export(HttpServletResponse response, EpiparaChipSeqReqVO epiparaChipSeq)
    {
        SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMddHHmmss");
        List<EpiparaChipSeqRespVO> list = epiparaChipSeqService.list2(epiparaChipSeq);
        ExcelUtil<EpiparaChipSeqRespVO> util = new ExcelUtil<>(EpiparaChipSeqRespVO.class);
        util.exportExcel(response, list, sdf.format(new Date()));
    }

}
